package dao

import (
	"gold_task/db"
	"gold_task/db/model"

	log "github.com/sirupsen/logrus"
)

func GetReviewItemList(creator string) (res []model.ReviewItem, err error) {
	err = db.Get().Where("creator = ?", creator).Find(&res).Error
	if err != nil {
		log.Warnf("error is %v", err)
	}
	return
}

func AddReviewItem(r *model.ReviewItem) (err error) {
	err = db.Get().Create(r).Error
	if err != nil {
		log.Warnf("error is %v", err)
	}
	return
}
func UpdateReviewItem(r model.ReviewItem) (err error) {
	err = db.Get().Table(r.TableName()).Where("id=? and creator=? and task_id=?",
		r.Id, r.Creator, r.TaskId).Update("status", r.Status).Error
	if err != nil {
		log.Warnf("error is %v", err)
	}
	return
}
